home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Snippets / vListMngr 1.0 / Sources ƒ / DemoList_Window < prev    next >
Encoding:
Text File  |  1996-04-10  |  2.6 KB  |  85 lines  |  [TEXT/PJMM]

  1. unit DemoList_Window;
  2.  
  3. {File name: DemoList_Window}
  4. {Function: Handle a Window}
  5. {History: 6/3/92 Original by Prototyper.   }
  6.  
  7. interface
  8.     uses
  9.         vListMngr, vListDemo_Globals;
  10.  
  11.     {Initialize us so all our routines can be activated}
  12.     procedure Init_DemoList_Window;
  13.  
  14.     {Open our window and draw everything}
  15.     procedure Open_DemoList_Window;
  16.  
  17.     {Update our window, someone uncovered a part of us}
  18.     procedure Update_DemoList_Window (whichWindow: WindowPtr);
  19.  
  20.     {Close our window}
  21.     procedure Close_DemoList_Window (whichWindow: WindowPtr);
  22.  
  23. implementation
  24.     var
  25.         MyWindow: WindowPtr;           {Window pointer}
  26.         tempRect, temp2Rect: Rect;      {Temporary rectangle}
  27.         Index: Integer;                        {For looping}
  28.  
  29.  
  30.     {Initialize us so all our routines can be activated}
  31.     procedure Init_DemoList_Window;
  32.     begin                               {Start of Window initialize routine}
  33.         MyWindow := nil;                  {Make sure other routines know we are not valid yet}
  34.     end;                                {End of procedure}
  35.  
  36.  
  37.     {Update our window, someone uncovered a part of us}
  38.     procedure Update_DemoList_Window (whichWindow: WindowPtr);
  39.         var
  40.             SavePort: WindowPtr;
  41.     begin
  42.         if (MyWindow <> nil) and (MyWindow = whichWindow) then{Handle an open when already opened}
  43.             begin
  44.                 GetPort(SavePort);
  45.                 SetPort(MyWindow);
  46.                 vlUpdate(MyWindow^.visRgn, DemoList);
  47.                 DrawControls(MyWindow);                        {Draw all the controls}
  48.                 SetPort(SavePort);                                  {Restore the old port}
  49.                 DrawGrowIcon(MyWindow);                        {Draw the grow Icon again}
  50.             end;        {End for if (MyWindow<>nil)}
  51.     end;
  52.  
  53.  
  54.     {Open our window and draw everything}
  55.     procedure Open_DemoList_Window;
  56.     begin
  57.         if (MyWindow = nil) then                {Handle an open when already opened}
  58.             begin
  59.                 SetRect(tempRect, 0, 0, 400, 300);
  60.                 OffsetRect(tempRect, 10, 45);
  61.                 MyWindow := NewWindow(nil, tempRect, 'vList Demo', TRUE, documentProc, WindowPtr(-1), TRUE, 0);
  62.                 DemoListWindow := MyWindow;
  63.                 SetPort(MyWindow);                  {Prepare to write into our window}
  64.     {Set the default application font}
  65.                 TextFont(3);                            {geneva}
  66.                 TextSize(9);
  67.                 TextFace([]);
  68.                 ShowWindow(MyWindow);               {Show the window now}
  69.                 SelectWindow(MyWindow);            {Bring our window to the front}
  70.             end         {if (MyWindow = nil)}
  71.         else
  72.             SelectWindow(MyWindow);        {Already open, so show it}
  73.     end;            {procedure Open_DemoList_Window}
  74.  
  75.     procedure Close_DemoList_Window (whichWindow: WindowPtr);
  76.     begin                               {Start of Window close routine}
  77.         if (MyWindow <> nil) and ((MyWindow = whichWindow) or (ord4(whichWindow) = -1)) then{See if we should close this window}
  78.             begin
  79.                 DisposeWindow(MyWindow);    {Clear window and controls}
  80.                 MyWindow := nil;                    {Make sure other routines know we are open}
  81.             end;
  82.     end;        {procedure Close_DemoList_Window}
  83.  
  84.  
  85. end.